package com.logistics.map.entity.model;

import com.logistics.map.entity.domain.Map;
import com.logistics.utils.aspect.annotation.Dictionary;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;

import java.util.List;

@Data
public class MapRow {

    private Integer id;
    private String name;
    @Dictionary(key = "map_type")
    private String type;
    private String remark;
    private String path;
    private String creator;
    private String createTime;
    private String updater;
    private String updateTime;
    private List<MapComponentsRow> nodes;
    private List<MapRouteEdgesRow> edges;

    public MapRow(){

    }

    public MapRow(Map map){
        this.id = map.getId();
        this.name = map.getName();
        this.type = map.getType();
        this.remark = map.getRemark();
        this.path = map.getPath();
        this.creator = map.getCreator();
        this.createTime = DateUtils.dateToStringFormat(map.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = map.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(map.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static MapRow build(Map map){
        return new MapRow(map);
    }
}
